package cn.dankal.flyaudio.adapter;

import android.view.View;
import android.view.ViewGroup;

import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter;
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder;
import cn.dankal.flyaudio.R;
import cn.dankal.flyaudio.entity.SignRewardEntity;
import cn.dankal.flyaudio.friend.pickimage.StringUtil;

public class SignRewardAdapter extends BaseRecyclerViewAdapter<SignRewardEntity> {
    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_sign_reward;
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(ViewGroup parent, View rootView, int viewType) {
        return new ViewHolder(rootView);
    }

    private String continuousCount;

    public void setContinuousCount(String continuousCount) {
        this.continuousCount = continuousCount;
    }

    class ViewHolder extends BaseRecyclerViewHolder<SignRewardEntity>{

        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        public void onBindData(SignRewardEntity data, int position) {
            setText(R.id.tv_reward_day,"第"+data.getDay()+"天");
            setText(R.id.tv_reward_score,"积分红包\n价值"+data.getScores()+"积分");
            String text = "";
            int day = Integer.valueOf(data.getDay());


            if(StringUtil.isEmpty(continuousCount)){
                text = "还剩"+data.getDay()+"天";
            }else{
                int countDay = day-Integer.valueOf(continuousCount);
                if(countDay<1){
                    text = "已领取";
                }else{
                    text =  "还剩"+countDay+"天";
                }
            }
            setText(R.id.tv_continuousCount, text);
        }
    }
}
